package com.lyloou.demo.controller;

import com.lyloou.demo.service.DemoService;
import com.lyloou.mvcframework.annotation.MyAutowired;
import com.lyloou.mvcframework.annotation.MyController;
import com.lyloou.mvcframework.annotation.MyRequestMapping;
import com.lyloou.mvcframework.annotation.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author lyloou
 * @date 2020/06/13
 * @desc
 */
@MyController
@MyRequestMapping("/demo")
public class DemoController {
    @MyAutowired
    DemoService demoService;

    @MyRequestMapping("/query")
    public String query(HttpServletRequest req, HttpServletResponse resp, String name) throws IOException {
        System.out.println("query from demoController:" + name);
        resp.getWriter().write(name);
        return name;
    }

    @MyRequestMapping("/handle01")
    @Security({"zhangsan", "lisi"})
    public String handle01(HttpServletRequest req, HttpServletResponse resp, String username) throws IOException {
        resp.getWriter().write("hello, " + username);
        return username;
    }
}
